<template>
    <div class="top">
        <div class="content">
            <!-- 左侧 -->
            <div class="left" @click="goHome">
                <img src="../../assets/favicon.ico" alt="">
                <p>医院挂号 预约挂号统一平台</p>
            </div>
            <!-- 右侧 -->
            <div class="right">
                <p class="help" @click="help">帮助中心</p>
                <p class="login" @click="userStore.visible = true" v-if="!userStore.info.name">登录/注册</p>
                <el-dropdown v-else>
                    <span class="el-dropdown-link">
                      {{ userStore.info.name }}
                      <el-icon class="el-icon--right">
                        <arrow-down />
                      </el-icon>
                    </span>
                    <template #dropdown>
                      <el-dropdown-menu>
                        <el-dropdown-item @click="$router.push({path:'/user/approve'})">实名认证</el-dropdown-item>
                        <el-dropdown-item @click="$router.push({path:'/user/order'})">挂号订单</el-dropdown-item>
                        <el-dropdown-item @click="goUser">就诊人管理</el-dropdown-item>
                        <el-dropdown-item @click="logout">退出登录</el-dropdown-item>
                      </el-dropdown-menu>
                    </template>
                </el-dropdown>
            </div>
        </div>
    </div>
</template>

<script setup lang="ts" name="Top">
    import {useRouter} from "vue-router";
    // 获取仓库内容，主要是visible控制显示与隐藏
    import useUserStore from "@/store/modules/user";
    import {ArrowDown} from "@element-plus/icons-vue";
    let userStore = useUserStore();

    const $router = useRouter();
    const goHome = () => {
            $router.push({path:'/home'});
        }
    const goUser = () => {
        $router.push({path:'/user/patient'});
    }

    // 用户帮助
    const help = () => {
        alert('如有任何疑问，请致电13541738430咨询帮助');
    }
    // 退出登录
    const logout = () => {
        userStore.logout();
        $router.push({path:'/home'});
    }
</script>

<style scoped>
    .top{
        position: fixed;
        z-index: 999;
        width: 100%;
        height: 70px;
        background-color: #fff;
        display: flex;
        justify-content: center;
        box-shadow: rgb(0,0,0,0.1) 0 0 10px 0;
    }
    .content{
        width: 1200px;
        height: 70px;
        background-color: white;
        display: flex;
        justify-content: space-between;
        .left:hover{
            cursor: pointer;
        }
        .left{
            display: flex;
            justify-content: center;
            align-items: center;
            margin-right: 20px;
            img{
                width: 50px;
                height: 50px;
            }
            p{
                font-size: 20px;
                color: #55a6fe;
            }
        }

        .right{
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 14px;
            color: #bbb;
            .help{
                margin-right: 20px;
            }
            .el-dropdown-link:hover{
                cursor: pointer;
            }
        }
        p:hover{
            cursor: pointer;
        }
    }
</style>